<template>
	<view>
		<uni-section title="内容汇总" type="line">
			<view v-for="(i, index) in data" :key="index">
				<uni-card :title="i.title" :thumbnail="i.uri" @click.stop="toDetail(i.id)">
					<text class="uni-body">{{i.memo}}</text>
				
				<view slot="actions" class="card-actions no-border">
					
					<view class="card-actions-item" @click.stop="good(i.id)">
						<uni-icons type="hand-up" size="18" color="#999"></uni-icons>
						<text class="card-actions-item-text">点赞</text>
					</view>
					
				</view>
				</uni-card>
			</view>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				type: "hand-up"
			}
		},
		methods: {
			good(id) {
				var _this = this;
				console.log("点赞")
				uni.request({
					url: 'http://xg.kystu.cn:8085/system/ok/click',
					method: 'POST',
					header: {
						'Authorization': "Bearer " + _this.token
					},
					data: {
						"tableId": id,
						"tableType": "record"
					},
					success: (res) => {
						

					}
				})

			},
			toDetail(id) {
				uni.navigateTo({
					url: '/pages/els/detail/detail?index=' + id
				});
			},
			onShow() {
				var _this = this;
				uni.getStorage({
					key: 'App-Token',
					success(res) {
						_this.token = res.data;
						uni.request({
							url: 'http://xg.kystu.cn:8085/system/projectcontent_cj/list',
							method: 'GET',
							header: {
								'Authorization': "Bearer " + _this.token
							},
							success: (res) => {
								if (res.data.code == 200) {
									_this.data = []
									for (var i = 0; i < res.data.total; i++) {
										_this.data.push({
											'title': '',
											'memo': '',
											'uri': '',
											'updatetime': '',
											'username': '',
											'id': ''
										})
										console.log(res.data.rows[i].title)
										_this.data[i].title = res.data.rows[i].title;
										_this.data[i].memo = res.data.rows[i].mycontent;
										var m = res.data.rows[i].upimage.split(",");
										_this.data[i].uri = 'http://xg.kystu.cn:8085' + m[0];
										_this.data[i].updatetime = res.data.rows[i].updatetime;
										_this.data[i].username = 'http://xg.kystu.cn:8085' + res.data
											.rows[i].username;
										_this.data[i].id = res.data.rows[i].id;
									}
								}

							}
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>
